package com.vichat.common.util;

/**
 * @version v 1.0 on 2015/11/5 15:30
 * @auther william.xu
 */
public final class K
{
    private static byte[] key = { 97, 105, 95, 110, 106, 95, 114, 100 };

    private K()
            throws Exception
    {}

    public static String j(String plain)
            throws Exception
    {
        RC2 rc2 = new RC2();
        return rc2.encrypt_rc2_array_base64(plain.getBytes(), key);
    }

    public static String k(String cipher)
            throws Exception
    {
        RC2 rc2 = new RC2();
        return rc2.decrypt_rc2_array_base64(cipher.getBytes(), key);
    }

    public static String k_s(String cipher)
            throws Exception
    {
        String rtn = null;
        if ((cipher != null) && (cipher.lastIndexOf("{RC2}") != -1)) {
            rtn = k(cipher.substring(5));
        } else {
            rtn = cipher;
        }
        return rtn;
    }

    public static void main2(String[] args)
            throws Exception
    {
        String a = k_s("{RC2}RcAeFXsjJHfGNA==");
        System.out.println(a);
    }


    public static void main(String[] args)
            throws Exception
    {


        System.out.println(K.j("Nd2018!@#$"));
//        System.out.println(K.k_s("{RC2}8StrPaIJ"));


    }
}
